#!/bin/sh
if ! grep -q '^frisbee_mode=1' /etc/frisbee/frisbee.conf;then
	sed -i -e '/^frisbee_mode=/ s/=.*/=1/' /etc/frisbee/frisbee.conf #set frisbee mode in effect
	if [ -f /etc/dhcpcd_state_notify ];then
		grep -q '^dhcpcd_state_notify=1' /etc/frisbee/frisbee.conf \
		 || sed -i -e '/^dhcpcd_state_notify=/ s/=.*/=1/' /etc/frisbee/frisbee.conf #on before frisbee mode
		grep -q '^announce_state_changes=1' /etc/frisbee/frisbee.conf \
		 || rm -f /etc/dhcpcd_state_notify
	else
		grep -q '^dhcpcd_state_notify=0' /etc/frisbee/frisbee.conf \
		 || sed -i -e '/^dhcpcd_state_notify=/ s/=.*/=0/' /etc/frisbee/frisbee.conf #off before frisbee mode
		grep -q '^announce_state_changes=1' /etc/frisbee/frisbee.conf \
		 && touch /etc/dhcpcd_state_notify
	fi
fi

